package edu.gdut.tiantian.controller;
/*
 * 配置SpringMVC拦截器
 */
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;

public class UserInterceptor implements HandlerInterceptor{
	@Override
	public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler)
			throws Exception {
			if(req.getSession().getAttribute("user")!=null) {
				return true;
			}
			req.getSession().setAttribute("msg","您尚未登录!");
			resp.sendRedirect(req.getContextPath()+"/pages/user/login.jsp");
			return false;
	}
}
